/*
 * @Author: yangni 920556271@qq.com
 * @Date: 2024-05-21 14:48:16
 * @LastEditors: yangni 920556271@qq.com
 * @LastEditTime: 2024-05-21 15:33:19
 * @FilePath: /yt-devops/lib/styles/fonts.dart
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
part of styles;

extension TextStyles on TextStyle {
  /// 主色、常规字重 style
  static TextStyle f11 = styleWith(11.sp);
  static TextStyle f12 = styleWith(12.sp);
  static TextStyle f14 = styleWith(14.sp);
  static TextStyle f16 = styleWith(16.sp);
  static TextStyle f17 = styleWith(17.sp);
  static TextStyle f18 = styleWith(18.sp);
  static TextStyle f20 = styleWith(20.sp);
  static TextStyle f22 = styleWith(22.sp);
  static TextStyle f24 = styleWith(24.sp);
  static TextStyle f26 = styleWith(26.sp);
  static TextStyle f30 = styleWith(30.sp);

  /// 浅色 style

  static TextStyle lf11 = styleWith(11.sp, color: Colour.lightTextColor);
  static TextStyle lf12 = styleWith(12.sp, color: Colour.lightTextColor);
  static TextStyle lf14 = styleWith(14.sp, color: Colour.lightTextColor);
  static TextStyle lf16 = styleWith(16.sp, color: Colour.lightTextColor);

  /// 主题配色style

  static TextStyle pf12 = styleWith(12.sp, color: Colour.primaryColor);
  static TextStyle pf14 = styleWith(14.sp, color: Colour.primaryColor);
  static TextStyle pf16 = styleWith(16.sp, color: Colour.primaryColor);
  static TextStyle pf18 = styleWith(18.sp, color: Colour.primaryColor);
  static TextStyle pf20 = styleWith(20.sp, color: Colour.primaryColor);

  /// 特殊 style 的通用构建方法
  static TextStyle styleWith(double? fontSize,
      {Color color = Colour.mainTextColor,
      FontWeight weight = FontWeight.normal}) {
    double height = 1;
    if (fontSize != null && fontSize > 12.sp) {
      height = 1.5;
    }
    return TextStyle(
        fontSize: fontSize,
        color: color,
        fontWeight: weight,
        height: height,
        fontFamilyFallback: const ["PingFang SC", "Heiti SC"]);
  }

  /// 反转色 style
  /// color 属性 为 null 的话，返回自身色的 style
  TextStyle get inverseColorStyle {
    if (color != null) {
      return TextStyle(
          fontSize: fontSize,
          color: color!.inverseColor,
          fontWeight: FontWeight.bold);
    } else {
      return TextStyle(
          fontSize: fontSize, color: color, fontWeight: FontWeight.bold);
    }
  }

  /// 警告 style
  TextStyle get warningColorStyle {
    return copyWith(
        color: Colour.warningTextColor, fontWeight: FontWeight.bold);
    //  TextStyle(
    //     fontSize: fontSize,
    //     color: Colour.warningTextColor,
    //     fontWeight: FontWeight.bold);
  }

  /// 错误 style
  TextStyle get errorColorStyle {
    return copyWith(color: Colour.errorTextColor, fontWeight: FontWeight.bold);

    // TextStyle(
    //     fontSize: fontSize,
    //     color: Colour.errorTextColor,
    //     fontWeight: FontWeight.bold);
  }

  /// bold 字重
  TextStyle get boldStyle {
    return copyWith(fontWeight: FontWeight.bold);
  }

  /// medium 字重
  TextStyle get mediumStyle {
    return copyWith(fontWeight: FontWeight.w500);
  }

  TextStyle get dinStyle {
    return copyWith(fontFamily: 'DIN');
  }
}
